import { applyMiddleware, createStore } from 'redux'
import { createBrowserHistory } from 'history'
import { routerMiddleware } from 'connected-react-router'
// 引入reducers里的所有单个reducer的相关信息, 与store建立起联系
import createRootReducer from './reducers'
import { composeWithDevTools } from 'redux-devtools-extension'
import rootSaga from './saga/rootSaga'
import createSagaMiddleware from 'redux-saga'

export const history = createBrowserHistory()
const sagaMiddleware = createSagaMiddleware()
const store = createStore(
	createRootReducer(history),
	composeWithDevTools(
		applyMiddleware(routerMiddleware(history),sagaMiddleware)
	)
)
sagaMiddleware.run(rootSaga)
export default store